home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / term-source.lha / Extras / Source / term-Source.lha / RatePanel.c < prev    next >
C/C++ Source or Header  |  1995-03-20  |  30KB  |  1,308 lines

  1. /*
  2. **    RatePanel.c
  3. **
  4. **    Editing panel for phone units configuration
  5. **
  6. **    Copyright © 1990-1995 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12. enum    {    GAD_TIME=1,GAD_ADDTIME,GAD_REMOVETIME,GAD_EDITTIME,
  13.         GAD_PAY1,GAD_MINUTES1,
  14.         GAD_PAY2,GAD_MINUTES2,
  15.         GAD_LIST,
  16.         GAD_ADDDATE,GAD_ADDDAY,GAD_EDIT,
  17.         GAD_CLONE,GAD_REMOVE,GAD_IMPORT
  18.     };
  19.  
  20. struct DoubleInfo
  21. {
  22.     LONG    GlyphWidth,
  23.         HeaderLen;
  24. };
  25.  
  26.     /* ListViewRender():
  27.      *
  28.      *    This callback routine is responsible for rendering
  29.      *    the single listview entries.
  30.      */
  31.  
  32. STATIC ULONG __saveds __asm
  33. ListViewRender(register __a0 struct Hook *Hook,register __a1 struct LVDrawMsg *Msg,register __a2 struct Node *Node)
  34. {
  35.         /* We only know how to redraw lines. */
  36.  
  37.     if(Msg -> lvdm_MethodID == LV_DRAW)
  38.     {
  39.         struct RastPort        *RPort    = Msg -> lvdm_RastPort;
  40.         LONG             Left    = Msg -> lvdm_Bounds . MinX,
  41.                      Top    = Msg -> lvdm_Bounds . MinY,
  42.                      Width    = Msg -> lvdm_Bounds . MaxX - Msg -> lvdm_Bounds . MinX + 1,
  43.                      Height    = Msg -> lvdm_Bounds . MaxY - Msg -> lvdm_Bounds . MinY + 1,
  44.                      Delta,
  45.                      FgPen,BgPen,
  46.                      Len,LabelLen,Template;
  47.         UBYTE            *String,Header[8];
  48.         struct DoubleInfo    *Info;
  49.  
  50.         Info = Hook -> h_Data;
  51.  
  52.         String = &Node -> ln_Name[Info -> HeaderLen];
  53.  
  54.         memcpy(Header,Node -> ln_Name,Info -> HeaderLen);
  55.  
  56.         Header[Info -> HeaderLen] = 0;
  57.  
  58.             /* Determine the rendering pens. */
  59.  
  60.         switch(Msg -> lvdm_State)
  61.         {
  62.             case LVR_SELECTEDDISABLED:
  63.             case LVR_NORMALDISABLED:
  64.             case LVR_NORMAL:
  65.  
  66.                 FgPen = Msg -> lvdm_DrawInfo -> dri_Pens[TEXTPEN];
  67.                 BgPen = Msg -> lvdm_DrawInfo -> dri_Pens[BACKGROUNDPEN];
  68.                 break;
  69.  
  70.             case LVR_SELECTED:
  71.  
  72.                 FgPen = Msg -> lvdm_DrawInfo -> dri_Pens[FILLTEXTPEN];
  73.                 BgPen = Msg -> lvdm_DrawInfo -> dri_Pens[FILLPEN];
  74.                 break;
  75.         }
  76.  
  77.         SetAPen(RPort,BgPen);
  78.         RectFill(RPort,Left,Top,Left + 1,Top + Height - 1);
  79.  
  80.         Left    += 2;
  81.         Width    -= 2;
  82.  
  83.             /* Set the rendering pens. */
  84.  
  85.         SetDrMd(RPort,JAM2);
  86.         SetBPen(RPort,BgPen);
  87.  
  88.         Template = Info -> HeaderLen * Info -> GlyphWidth;
  89.  
  90.             /* Determine header length. */
  91.  
  92.         Len = TextLength(RPort,Header,Info -> HeaderLen);
  93.  
  94.             /* Fill the space to precede the header. */
  95.  
  96.         if((Delta = Template - Len) > 0)
  97.         {
  98.             SetAPen(RPort,BgPen);
  99.             RectFill(RPort,Left,Top,Left + Delta - 1,Top + Height - 1);
  100.         }
  101.  
  102.             /* Render the header, right-justified. */
  103.  
  104.         SetAPen(RPort,FgPen);
  105.  
  106.         Move(RPort,Left + Delta,Top + RPort -> Font -> tf_Baseline);
  107.         Text(RPort,Header,Info -> HeaderLen);
  108.  
  109.             /* Adjust width and area left edge. */
  110.  
  111.         Left    += Template;
  112.         Width    -= Template;
  113.  
  114.             /* Determine length of vanilla name. */
  115.  
  116.         LabelLen = strlen(String);
  117.  
  118.             /* Try to make it fit. */
  119.  
  120.         while(LabelLen > 0 && (Len = TextLength(RPort,String,LabelLen)) > Width)
  121.             LabelLen--;
  122.  
  123.             /* Print the vanilla name if possible. */
  124.  
  125.         if(LabelLen)
  126.         {
  127.             Move(RPort,Left,Top + RPort -> Font -> tf_Baseline);
  128.             Text(RPort,String,LabelLen);
  129.  
  130.             Left    += Len;
  131.             Width    -= Len;
  132.         }
  133.  
  134.             /* Fill the area to follow the vanilla name. */
  135.  
  136.         if(Width > 0)
  137.         {
  138.             SetAPen(RPort,BgPen);
  139.             RectFill(RPort,Left,Top,Left + Width - 1,Top + Height - 1);
  140.         }
  141.  
  142.             /* If the item happens to be disabled, draw the cross-hatch
  143.              * pattern across it.
  144.              */
  145.  
  146.         if(Msg -> lvdm_State == LVR_SELECTEDDISABLED || Msg -> lvdm_State == LVR_NORMALDISABLED)
  147.         {
  148.             SetDrMd(RPort,JAM1);
  149.  
  150.             SetAPen(RPort,Msg -> lvdm_DrawInfo -> dri_Pens[BLOCKPEN]);
  151.  
  152.             SetAfPt(RPort,(UWORD *)&Ghosting,1);
  153.  
  154.             RectFill(RPort,Msg -> lvdm_Bounds . MinX,Msg -> lvdm_Bounds . MinY,Msg -> lvdm_Bounds . MaxX,Msg -> lvdm_Bounds . MaxY);
  155.  
  156.             SetAfPt(RPort,NULL,0);
  157.         }
  158.  
  159.         return(LVCB_OK);
  160.     }
  161.     else
  162.         return(LVCB_UNKNOWN);
  163. }
  164.  
  165. STATIC VOID __regargs
  166. DisableGadgets(struct LayoutHandle *Handle,BOOLEAN Mode,BOOLEAN SetEntries,BOOLEAN SetTime)
  167. {
  168.     LT_SetAttributes(Handle,GAD_PAY1,
  169.         GA_Disabled,    Mode,
  170.     TAG_DONE);
  171.  
  172.     LT_SetAttributes(Handle,GAD_MINUTES1,
  173.         GA_Disabled,    Mode,
  174.     TAG_DONE);
  175.  
  176.     LT_SetAttributes(Handle,GAD_PAY2,
  177.         GA_Disabled,    Mode,
  178.     TAG_DONE);
  179.  
  180.     LT_SetAttributes(Handle,GAD_MINUTES2,
  181.         GA_Disabled,    Mode,
  182.     TAG_DONE);
  183.  
  184.     if(SetEntries)
  185.     {
  186.         LT_SetAttributes(Handle,GAD_EDIT,
  187.             GA_Disabled,    Mode,
  188.         TAG_DONE);
  189.  
  190.         LT_SetAttributes(Handle,GAD_CLONE,
  191.             GA_Disabled,    Mode,
  192.         TAG_DONE);
  193.  
  194.         LT_SetAttributes(Handle,GAD_REMOVE,
  195.             GA_Disabled,    Mode,
  196.         TAG_DONE);
  197.     }
  198.  
  199.     if(SetTime)
  200.     {
  201.         LT_SetAttributes(Handle,GAD_TIME,
  202.             GA_Disabled,    Mode,
  203.         TAG_DONE);
  204.  
  205.         LT_SetAttributes(Handle,GAD_ADDTIME,
  206.             GA_Disabled,    Mode,
  207.         TAG_DONE);
  208.  
  209.         LT_SetAttributes(Handle,GAD_REMOVETIME,
  210.             GA_Disabled,    Mode,
  211.         TAG_DONE);
  212.  
  213.         LT_SetAttributes(Handle,GAD_EDITTIME,
  214.             GA_Disabled,    Mode,
  215.         TAG_DONE);
  216.     }
  217. }
  218.  
  219. BYTE __regargs
  220. RatePanel(struct Window *Parent,struct List *PhoneList,struct PhoneEntry *Entry,struct List *TimeDateList)
  221. {
  222.     STATIC struct DoubleInfo TimeInfo;
  223.  
  224.     STATIC struct Hook TimeHook =
  225.     {
  226.         {NULL},
  227.         (HOOKFUNC)ListViewRender,
  228.         (HOOKFUNC)NULL,
  229.         &TimeInfo
  230.     };
  231.  
  232.     STATIC struct DoubleInfo DateInfo;
  233.  
  234.     STATIC struct Hook DateHook =
  235.     {
  236.         {NULL},
  237.         (HOOKFUNC)ListViewRender,
  238.         (HOOKFUNC)NULL,
  239.         &DateInfo
  240.     };
  241.  
  242.     struct LayoutHandle    *Handle;
  243.     BYTE             MadeChanges = FALSE;
  244.  
  245.     if(!TimeDateList)
  246.         TimeDateList = (struct List *)&Entry -> TimeDateList;
  247.  
  248.     if(Handle = LT_CreateHandleTags(Parent -> WScreen,
  249.         LH_LocaleHook,    &LocaleHook,
  250.     TAG_DONE))
  251.     {
  252.         struct Window    *PanelWindow;
  253.         LONG         i,Max = 0,Size;
  254.         UBYTE         SmallString[2];
  255.  
  256.         SmallString[1] = 0;
  257.  
  258.         for(i = '0' ; i <= '9' ; i++)
  259.         {
  260.             SmallString[0] = i;
  261.  
  262.             if((Size = LT_LabelWidth(Handle,SmallString)) > Max)
  263.                 Max = Size;
  264.         }
  265.  
  266.         TimeInfo . GlyphWidth    = Max;
  267.         TimeInfo . HeaderLen    = 2;
  268.  
  269.         DateInfo . GlyphWidth    = Max;
  270.         DateInfo . HeaderLen    = 7;
  271.  
  272.         LT_New(Handle,
  273.             LA_Type,    VERTICAL_KIND,
  274.         TAG_DONE);
  275.         {
  276.             LT_New(Handle,
  277.                 LA_Type,    HORIZONTAL_KIND,
  278.             TAG_DONE);
  279.             {
  280.                 LT_New(Handle,
  281.                     LA_Type,    VERTICAL_KIND,
  282.                     LA_LabelID,    MSG_V36_0156,
  283.                 TAG_DONE);
  284.                 {
  285.                     LT_New(Handle,
  286.                         LA_Type,    LISTVIEW_KIND,
  287.                         LA_LabelID,    MSG_RATEPANEL_TIME_GAD,
  288.                         LA_Chars,    10,
  289.                         LA_Lines,    6,
  290.                         LA_ID,        GAD_TIME,
  291.                         GA_Disabled,    TRUE,
  292.                         GTLV_CallBack,    &TimeHook,
  293.                         LALV_Link,    NIL_LINK,
  294.                     TAG_DONE);
  295.  
  296.                     LT_New(Handle,
  297.                         LA_Type,    BUTTON_KIND,
  298.                         LA_LabelID,    MSG_RATEPANEL_ADD_TIME_GAD,
  299.                         LA_ID,        GAD_ADDTIME,
  300.                         GA_Disabled,    TRUE,
  301.                     TAG_DONE);
  302.  
  303.                     LT_New(Handle,
  304.                         LA_Type,    BUTTON_KIND,
  305.                         LA_LabelID,    MSG_RATEPANEL_REMOVE_TIME_GAD,
  306.                         LA_ID,        GAD_REMOVETIME,
  307.                         GA_Disabled,    TRUE,
  308.                     TAG_DONE);
  309.  
  310.                     LT_New(Handle,
  311.                         LA_Type,    BUTTON_KIND,
  312.                         LA_LabelID,    MSG_RATEPANEL_EDIT_TIME_GAD,
  313.                         LA_ID,        GAD_EDITTIME,
  314.                         GA_Disabled,    TRUE,
  315.                     TAG_DONE);
  316.  
  317.                     LT_EndGroup(Handle);
  318.                 }
  319.  
  320.                 LT_New(Handle,
  321.                     LA_Type,    HORIZONTAL_KIND,
  322.                     LA_LabelID,    MSG_V36_0157,
  323.                 TAG_DONE);
  324.                 {
  325.                     LT_New(Handle,
  326.                         LA_Type,    VERTICAL_KIND,
  327.                     TAG_DONE);
  328.                     {
  329.                         LT_New(Handle,
  330.                             LA_Type,    VERTICAL_KIND,
  331.                             LA_LabelID,    MSG_RATEPANEL_FIRST_UNIT_GAD,
  332.                         TAG_DONE);
  333.                         {
  334.                             LT_New(Handle,
  335.                                 LA_Type,        INTEGER_KIND,
  336.                                 LA_LabelText,        SmallCurrency(),
  337.                                 LA_Chars,        4,
  338.                                 LA_ID,            GAD_PAY1,
  339.                                 LAIN_UseIncrementers,    TRUE,
  340.                                 LAIN_Min,        0,
  341.                                 GA_Disabled,        TRUE,
  342.                             TAG_DONE);
  343.  
  344.                             LT_New(Handle,
  345.                                 LA_Type,        INTEGER_KIND,
  346.                                 LA_LabelID,        MSG_RATEPANEL_SECONDS_PER_UNIT_GAD,
  347.                                 LA_ID,            GAD_MINUTES1,
  348.                                 LAIN_UseIncrementers,    TRUE,
  349.                                 LAIN_Min,        0,
  350.                                 GA_Disabled,        TRUE,
  351.                             TAG_DONE);
  352.  
  353.                             LT_EndGroup(Handle);
  354.                         }
  355.  
  356.                         LT_New(Handle,
  357.                             LA_Type,    VERTICAL_KIND,
  358.                             LA_LabelID,    MSG_RATEPANEL_FOLLOWING_UNITS_GAD,
  359.                         TAG_DONE);
  360.                         {
  361.                             LT_New(Handle,
  362.                                 LA_Type,        INTEGER_KIND,
  363.                                 LA_LabelText,        SmallCurrency(),
  364.                                 LA_Chars,        4,
  365.                                 LA_ID,            GAD_PAY2,
  366.                                 LAIN_UseIncrementers,    TRUE,
  367.                                 LAIN_Min,        0,
  368.                                 GA_Disabled,        TRUE,
  369.                             TAG_DONE);
  370.  
  371.                             LT_New(Handle,
  372.                                 LA_Type,        INTEGER_KIND,
  373.                                 LA_LabelID,        MSG_RATEPANEL_SECONDS_PER_UNIT_GAD,
  374.                                 LA_ID,            GAD_MINUTES2,
  375.                                 LAIN_UseIncrementers,    TRUE,
  376.                                 LAIN_Min,        0,
  377.                                 GA_Disabled,        TRUE,
  378.                             TAG_DONE);
  379.  
  380.                             LT_EndGroup(Handle);
  381.                         }
  382.  
  383.                         LT_EndGroup(Handle);
  384.                     }
  385.  
  386.                     LT_New(Handle,
  387.                         LA_Type,    VERTICAL_KIND,
  388.                     TAG_DONE);
  389.                     {
  390.                         LT_New(Handle,
  391.                             LA_Type,    LISTVIEW_KIND,
  392.                             LA_LabelID,    MSG_RATEPANEL_DAYS_AND_DATES_GAD,
  393.                             LA_Chars,    30,
  394.                             LA_Lines,    10,
  395.                             LA_ID,        GAD_LIST,
  396.                             GTLV_CallBack,    &DateHook,
  397.                             GTLV_Labels,    TimeDateList,
  398.                             LALV_Link,    NIL_LINK,
  399.  
  400.                             Kick30 ? TAG_IGNORE : LALV_TextAttr, ~0,
  401.                         TAG_DONE);
  402.  
  403.                         LT_EndGroup(Handle);
  404.                     }
  405.  
  406.                     LT_EndGroup(Handle);
  407.                 }
  408.  
  409.                 LT_EndGroup(Handle);
  410.             }
  411.  
  412.             LT_New(Handle,
  413.                 LA_Type,    VERTICAL_KIND,
  414.             TAG_DONE);
  415.             {
  416.                 LT_New(Handle,LA_Type,XBAR_KIND,LAXB_FullSize,TRUE,TAG_DONE);
  417.  
  418.                 LT_EndGroup(Handle);
  419.             }
  420.  
  421.             LT_New(Handle,LA_Type,HORIZONTAL_KIND,
  422.                 LAGR_Spread,    TRUE,
  423.             TAG_DONE);
  424.             {
  425.                 LT_New(Handle,
  426.                     LA_Type,    BUTTON_KIND,
  427.                     LA_LabelID,    MSG_RATEPANEL_ADD_DATE_GAD,
  428.                     LA_ID,        GAD_ADDDATE,
  429.                     LABT_ExtraFat,    TRUE,
  430.                 TAG_DONE);
  431.  
  432.                 LT_New(Handle,
  433.                     LA_Type,    BUTTON_KIND,
  434.                     LA_LabelID,    MSG_RATEPANEL_ADD_DAYS_GAD,
  435.                     LA_ID,        GAD_ADDDAY,
  436.                     LABT_ExtraFat,    TRUE,
  437.                 TAG_DONE);
  438.  
  439.                 LT_New(Handle,
  440.                     LA_Type,    BUTTON_KIND,
  441.                     LA_LabelID,    MSG_RATEPANEL_EDIT_GAD,
  442.                     LA_ID,        GAD_EDIT,
  443.                     LABT_ExtraFat,    TRUE,
  444.                     GA_Disabled,    TRUE,
  445.                 TAG_DONE);
  446.  
  447.                 LT_New(Handle,
  448.                     LA_Type,    BUTTON_KIND,
  449.                     LA_LabelID,    MSG_RATEPANEL_CLONE_GAD,
  450.                     LA_ID,        GAD_CLONE,
  451.                     LABT_ExtraFat,    TRUE,
  452.                     GA_Disabled,    TRUE,
  453.                 TAG_DONE);
  454.  
  455.                 LT_New(Handle,
  456.                     LA_Type,    BUTTON_KIND,
  457.                     LA_LabelID,    MSG_GLOBAL_REMOVE_GAD,
  458.                     LA_ID,        GAD_REMOVE,
  459.                     LABT_ExtraFat,    TRUE,
  460.                     GA_Disabled,    TRUE,
  461.                 TAG_DONE);
  462.  
  463.                 LT_New(Handle,
  464.                     LA_Type,    BUTTON_KIND,
  465.                     LA_LabelID,    MSG_RATEPANEL_IMPORT_GAD,
  466.                     LA_ID,        GAD_IMPORT,
  467.                     LABT_ExtraFat,    TRUE,
  468.                     GA_Disabled,    !PhoneList,
  469.                 TAG_DONE);
  470.  
  471.                 LT_EndGroup(Handle);
  472.             }
  473.  
  474.             LT_EndGroup(Handle);
  475.         }
  476.  
  477.         if(PanelWindow = LT_Layout(Handle,LocaleString(MSG_RATEPANEL_RATES_PREFERENCES_TXT),NULL,0,0,IDCMP_CLOSEWINDOW,0,
  478.             LAWN_HelpHook,        &GuideHook,
  479.             WA_DepthGadget,        TRUE,
  480.             WA_CloseGadget,        TRUE,
  481.             WA_DragBar,        TRUE,
  482.             WA_RMBTrap,        TRUE,
  483.             WA_Activate,        TRUE,
  484.             LAWN_Parent,        Parent,
  485.         TAG_DONE))
  486.         {
  487.             struct IntuiMessage    *Message;
  488.             BOOLEAN             Done = FALSE;
  489.             ULONG             MsgClass,
  490.                          MsgQualifier;
  491.             UWORD             MsgCode;
  492.             struct Gadget        *MsgGadget;
  493.  
  494.             struct TimeDateNode    *TimeDateNode,
  495.                         *NewNode;
  496.             struct List        *TimeList    = NULL;
  497.             LONG             Selected    = ~0,
  498.                          Count        =  0,
  499.                          TimeSelected    = ~0;
  500.  
  501.             GuideContext(CONTEXT_RATES);
  502.  
  503.             TimeDateNode = (struct TimeDateNode *)TimeDateList -> lh_Head;
  504.  
  505.             while(TimeDateNode -> VanillaNode . ln_Succ)
  506.             {
  507.                 Count++;
  508.  
  509.                 TimeDateNode = (struct TimeDateNode *)TimeDateNode -> VanillaNode . ln_Succ;
  510.             }
  511.  
  512.             PushWindow(PanelWindow);
  513.  
  514.             LT_ShowWindow(Handle,TRUE);
  515.  
  516.             do
  517.             {
  518.                 if(Wait(PORTMASK(PanelWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
  519.                     break;
  520.  
  521.                 while(Message = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort))
  522.                 {
  523.                     MsgClass    = Message -> Class;
  524.                     MsgQualifier    = Message -> Qualifier;
  525.                     MsgCode        = Message -> Code;
  526.                     MsgGadget    = (struct Gadget *)Message -> IAddress;
  527.  
  528.                     GT_ReplyIMsg(Message);
  529.  
  530.                     LT_HandleInput(Handle,MsgQualifier,&MsgClass,&MsgCode,&MsgGadget);
  531.  
  532.                     if(MsgClass == IDCMP_CLOSEWINDOW)
  533.                         Done = TRUE;
  534.  
  535.                     if(MsgClass == IDCMP_GADGETUP)
  536.                     {
  537.                         switch(MsgGadget -> GadgetID)
  538.                         {
  539.                             case GAD_TIME:
  540.  
  541.                                 TimeSelected = MsgCode;
  542.  
  543.                                 if(Selected != ~0)
  544.                                 {
  545.                                     LT_SetAttributes(Handle,GAD_PAY1,
  546.                                         GTIN_Number,    TimeDateNode -> Table[TimeSelected] . PayPerUnit[DT_FIRST_UNIT],
  547.                                     TAG_DONE);
  548.  
  549.                                     LT_SetAttributes(Handle,GAD_MINUTES1,
  550.                                         GTIN_Number,    TimeDateNode -> Table[TimeSelected] . SecPerUnit[DT_FIRST_UNIT],
  551.                                     TAG_DONE);
  552.  
  553.                                     LT_SetAttributes(Handle,GAD_PAY2,
  554.                                         GTIN_Number,    TimeDateNode -> Table[TimeSelected] . PayPerUnit[DT_NEXT_UNIT],
  555.                                     TAG_DONE);
  556.  
  557.                                     LT_SetAttributes(Handle,GAD_MINUTES2,
  558.                                         GTIN_Number,    TimeDateNode -> Table[TimeSelected] . SecPerUnit[DT_NEXT_UNIT],
  559.                                     TAG_DONE);
  560.                                 }
  561.  
  562.                                 break;
  563.  
  564.                             case GAD_EDITTIME:
  565.  
  566.                                 if(Selected != ~0 && TimeSelected != ~0)
  567.                                 {
  568.                                     UBYTE Time = TimeDateNode -> Table[TimeSelected] . Time;
  569.  
  570.                                     LT_LockWindow(PanelWindow);
  571.  
  572.                                     if(TimePanel(&TimeDateNode -> Table[TimeSelected] . Time))
  573.                                     {
  574.                                         struct List *NewTimeList;
  575.  
  576.                                         MadeChanges = TRUE;
  577.  
  578.                                         SortTimeTable(TimeDateNode);
  579.  
  580.                                         if(NewTimeList = BuildTimeList(TimeDateNode))
  581.                                         {
  582.                                             LT_SetAttributes(Handle,GAD_TIME,
  583.                                                 GTLV_Labels,    ~0,
  584.                                             TAG_DONE);
  585.  
  586.                                             if(TimeList)
  587.                                                 FreeVecPooled(TimeList);
  588.  
  589.                                             TimeList = NewTimeList;
  590.  
  591.                                             LT_SetAttributes(Handle,GAD_TIME,
  592.                                                 GTLV_Labels,    TimeList,
  593.                                                 GTLV_Selected,    0,
  594.                                                 GA_Disabled,    FALSE,
  595.                                             TAG_DONE);
  596.  
  597.                                             LT_SetAttributes(Handle,GAD_LIST,
  598.                                                 GTLV_Labels,    ~0,
  599.                                             TAG_DONE);
  600.  
  601.                                             DisableGadgets(Handle,TRUE,TRUE,TRUE);
  602.  
  603.                                             LT_SetAttributes(Handle,GAD_LIST,
  604.                                                 GTLV_Labels,    TimeDateList,
  605.                                                 GTLV_Selected,    ~0,
  606.                                             TAG_DONE);
  607.  
  608.                                             Selected = ~0;
  609.  
  610.                                             TimeSelected = ~0;
  611.                                         }
  612.                                         else
  613.                                         {
  614.                                             TimeDateNode -> Table[TimeSelected] . Time = Time;
  615.  
  616.                                             SortTimeTable(TimeDateNode);
  617.  
  618.                                             DisplayBeep(PanelWindow -> WScreen);
  619.                                         }
  620.                                     }
  621.  
  622.                                     LT_UnlockWindow(PanelWindow);
  623.  
  624.                                     LT_ShowWindow(Handle,TRUE);
  625.                                 }
  626.  
  627.                                 break;
  628.  
  629.                             case GAD_REMOVETIME:
  630.  
  631.                                 if(Selected != ~0 && TimeSelected != ~0)
  632.                                 {
  633.                                     MadeChanges = TRUE;
  634.  
  635.                                     LT_LockWindow(PanelWindow);
  636.  
  637.                                     LT_SetAttributes(Handle,GAD_TIME,
  638.                                         GTLV_Labels,    ~0,
  639.                                     TAG_DONE);
  640.  
  641.                                     if(DeleteTimeDateNode(TimeDateNode,TimeSelected))
  642.                                     {
  643.                                         if(TimeList)
  644.                                             FreeVecPooled(TimeList);
  645.  
  646.                                         if(TimeList = BuildTimeList(TimeDateNode))
  647.                                         {
  648.                                             LT_SetAttributes(Handle,GAD_TIME,
  649.                                                 GTLV_Labels,    TimeList,
  650.                                                 GTLV_Selected,    0,
  651.                                                 GA_Disabled,    FALSE,
  652.                                             TAG_DONE);
  653.  
  654.                                             LT_SetAttributes(Handle,GAD_LIST,
  655.                                                 GTLV_Labels,    ~0,
  656.                                             TAG_DONE);
  657.  
  658.                                             DisableGadgets(Handle,TRUE,TRUE,TRUE);
  659.  
  660.                                             LT_SetAttributes(Handle,GAD_LIST,
  661.                                                 GTLV_Labels,    TimeDateList,
  662.                                                 GTLV_Selected,    ~0,
  663.                                             TAG_DONE);
  664.  
  665.                                             Selected = ~0;
  666.  
  667.                                             TimeSelected = ~0;
  668.                                         }
  669.                                         else
  670.                                         {
  671.                                             LT_SetAttributes(Handle,GAD_TIME,
  672.                                                 GTLV_Labels,    &EmptyList,
  673.                                             TAG_DONE);
  674.  
  675.                                             DisplayBeep(PanelWindow -> WScreen);
  676.                                         }
  677.                                     }
  678.                                     else
  679.                                     {
  680.                                         LT_SetAttributes(Handle,GAD_TIME,
  681.                                             GTLV_Labels,    TimeList,
  682.                                             GTLV_Selected,    TimeSelected,
  683.                                         TAG_DONE);
  684.  
  685.                                         DisplayBeep(PanelWindow -> WScreen);
  686.                                     }
  687.  
  688.                                     LT_UnlockWindow(PanelWindow);
  689.                                 }
  690.  
  691.                                 break;
  692.  
  693.                             case GAD_ADDTIME:
  694.  
  695.                                 if(Selected != ~0)
  696.                                 {
  697.                                     UBYTE Time = DT_GET_TIME(12,0);
  698.  
  699.                                     MadeChanges = TRUE;
  700.  
  701.                                     LT_LockWindow(PanelWindow);
  702.  
  703.                                     if(TimePanel(&Time))
  704.                                     {
  705.                                         BYTE AddIt = TRUE;
  706.                                         LONG i;
  707.  
  708.                                         for(i = 0 ; i < TimeDateNode -> Table[0] . Count ; i++)
  709.                                         {
  710.                                             if(Time == TimeDateNode -> Table[i] . Time)
  711.                                             {
  712.                                                 AddIt = FALSE;
  713.                                                 break;
  714.                                             }
  715.                                         }
  716.  
  717.                                         if(AddIt)
  718.                                         {
  719.                                             LT_SetAttributes(Handle,GAD_TIME,
  720.                                                 GTLV_Labels,    ~0,
  721.                                             TAG_DONE);
  722.  
  723.                                             if(ResizeTimeDateNode(TimeDateNode,TimeDateNode -> Table[0] . Count + 1,Time))
  724.                                             {
  725.                                                 SortTimeTable(TimeDateNode);
  726.  
  727.                                                 if(TimeList)
  728.                                                     FreeVecPooled(TimeList);
  729.  
  730.                                                 if(TimeList = BuildTimeList(TimeDateNode))
  731.                                                 {
  732.                                                     LT_SetAttributes(Handle,GAD_TIME,
  733.                                                         GTLV_Labels,    TimeList,
  734.                                                         GTLV_Selected,    0,
  735.                                                         GA_Disabled,    FALSE,
  736.                                                     TAG_DONE);
  737.  
  738.                                                     LT_SetAttributes(Handle,GAD_LIST,
  739.                                                         GTLV_Labels,    ~0,
  740.                                                     TAG_DONE);
  741.  
  742.                                                     DisableGadgets(Handle,TRUE,TRUE,TRUE);
  743.  
  744.                                                     LT_SetAttributes(Handle,GAD_LIST,
  745.                                                         GTLV_Labels,    TimeDateList,
  746.                                                         GTLV_Selected,    ~0,
  747.                                                     TAG_DONE);
  748.  
  749.                                                     Selected = ~0;
  750.  
  751.                                                     TimeSelected = ~0;
  752.                                                 }
  753.                                                 else
  754.                                                 {
  755.                                                     LT_SetAttributes(Handle,GAD_TIME,
  756.                                                         GTLV_Labels,    &EmptyList,
  757.                                                     TAG_DONE);
  758.  
  759.                                                     DisplayBeep(PanelWindow -> WScreen);
  760.                                                 }
  761.                                             }
  762.                                             else
  763.                                             {
  764.                                                 LT_SetAttributes(Handle,GAD_TIME,
  765.                                                     GTLV_Labels,    TimeList,
  766.                                                     GTLV_Selected,    TimeSelected,
  767.                                                 TAG_DONE);
  768.  
  769.                                                 DisplayBeep(PanelWindow -> WScreen);
  770.                                             }
  771.                                         }
  772.                                     }
  773.  
  774.                                     LT_UnlockWindow(PanelWindow);
  775.  
  776.                                     LT_ShowWindow(Handle,TRUE);
  777.                                 }
  778.  
  779.                                 break;
  780.  
  781.                             case GAD_PAY1:
  782.  
  783.                                 TimeDateNode -> Table[TimeSelected] . PayPerUnit[DT_FIRST_UNIT] = LT_GetAttributes(Handle,MsgGadget -> GadgetID,TAG_DONE);
  784.  
  785.                                 MadeChanges = TRUE;
  786.  
  787.                                 break;
  788.  
  789.                             case GAD_PAY2:
  790.  
  791.                                 TimeDateNode -> Table[TimeSelected] . PayPerUnit[DT_NEXT_UNIT] = LT_GetAttributes(Handle,MsgGadget -> GadgetID,TAG_DONE);
  792.  
  793.                                 MadeChanges = TRUE;
  794.  
  795.                                 break;
  796.  
  797.                             case GAD_MINUTES1:
  798.  
  799.                                 TimeDateNode -> Table[TimeSelected] . SecPerUnit[DT_FIRST_UNIT] = LT_GetAttributes(Handle,MsgGadget -> GadgetID,TAG_DONE);
  800.  
  801.                                 MadeChanges = TRUE;
  802.  
  803.                                 break;
  804.  
  805.                             case GAD_MINUTES2:
  806.  
  807.                                 TimeDateNode -> Table[TimeSelected] . SecPerUnit[DT_NEXT_UNIT] = LT_GetAttributes(Handle,MsgGadget -> GadgetID,TAG_DONE);
  808.  
  809.                                 MadeChanges = TRUE;
  810.  
  811.                                 break;
  812.  
  813.                             case GAD_LIST:
  814.  
  815.                                 LT_SetAttributes(Handle,GAD_TIME,
  816.                                     GTLV_Labels,~0,
  817.                                 TAG_DONE);
  818.  
  819.                                 if(TimeList)
  820.                                     FreeVecPooled(TimeList);
  821.  
  822.                                 TimeDateNode = (struct TimeDateNode *)GetListNode(MsgCode,(struct List *)TimeDateList);
  823.  
  824.                                 if(TimeList = BuildTimeList(TimeDateNode))
  825.                                 {
  826.                                     TimeSelected = 0;
  827.  
  828.                                     Selected = MsgCode;
  829.  
  830.                                     DisableGadgets(Handle,FALSE,FALSE,FALSE);
  831.  
  832.                                     TimeDateNode = (struct TimeDateNode *)GetListNode(Selected,(struct List *)TimeDateList);
  833.  
  834.                                     LT_SetAttributes(Handle,GAD_PAY1,
  835.                                         GTIN_Number,    TimeDateNode -> Table[TimeSelected] . PayPerUnit[DT_FIRST_UNIT],
  836.                                     TAG_DONE);
  837.  
  838.                                     LT_SetAttributes(Handle,GAD_MINUTES1,
  839.                                         GTIN_Number,    TimeDateNode -> Table[TimeSelected] . SecPerUnit[DT_FIRST_UNIT],
  840.                                     TAG_DONE);
  841.  
  842.                                     LT_SetAttributes(Handle,GAD_PAY2,
  843.                                         GTIN_Number,    TimeDateNode -> Table[TimeSelected] . PayPerUnit[DT_NEXT_UNIT],
  844.                                     TAG_DONE);
  845.  
  846.                                     LT_SetAttributes(Handle,GAD_MINUTES2,
  847.                                         GTIN_Number,    TimeDateNode -> Table[TimeSelected] . SecPerUnit[DT_NEXT_UNIT],
  848.                                     TAG_DONE);
  849.  
  850.                                     LT_SetAttributes(Handle,GAD_TIME,
  851.                                         GTLV_Labels,    TimeList,
  852.                                         GTLV_Selected,    0,
  853.                                         GA_Disabled,    FALSE,
  854.                                     TAG_DONE);
  855.  
  856.                                     LT_SetAttributes(Handle,GAD_ADDTIME,
  857.                                         GA_Disabled,    FALSE,
  858.                                     TAG_DONE);
  859.  
  860.                                     LT_SetAttributes(Handle,GAD_REMOVETIME,
  861.                                         GA_Disabled,    TimeDateNode -> Table[0] . Count < 2,
  862.                                     TAG_DONE);
  863.  
  864.                                     LT_SetAttributes(Handle,GAD_EDITTIME,
  865.                                         GA_Disabled,    FALSE,
  866.                                     TAG_DONE);
  867.  
  868.                                     if(Selected)
  869.                                     {
  870.                                         LT_SetAttributes(Handle,GAD_EDIT,
  871.                                             GA_Disabled,    FALSE,
  872.                                         TAG_DONE);
  873.  
  874.                                         LT_SetAttributes(Handle,GAD_CLONE,
  875.                                             GA_Disabled,    FALSE,
  876.                                         TAG_DONE);
  877.  
  878.                                         LT_SetAttributes(Handle,GAD_REMOVE,
  879.                                             GA_Disabled,    FALSE,
  880.                                         TAG_DONE);
  881.                                     }
  882.                                     else
  883.                                     {
  884.                                         LT_SetAttributes(Handle,GAD_EDIT,
  885.                                             GA_Disabled,    TRUE,
  886.                                         TAG_DONE);
  887.  
  888.                                         LT_SetAttributes(Handle,GAD_CLONE,
  889.                                             GA_Disabled,    TRUE,
  890.                                         TAG_DONE);
  891.  
  892.                                         LT_SetAttributes(Handle,GAD_REMOVE,
  893.                                             GA_Disabled,    TRUE,
  894.                                         TAG_DONE);
  895.                                     }
  896.                                 }
  897.                                 else
  898.                                 {
  899.                                     TimeDateNode = NULL;
  900.  
  901.                                     DisplayBeep(PanelWindow -> WScreen);
  902.  
  903.                                     LT_SetAttributes(Handle,GAD_LIST,
  904.                                         GTLV_Labels,    ~0,
  905.                                     TAG_DONE);
  906.  
  907.                                     DisableGadgets(Handle,TRUE,TRUE,TRUE);
  908.  
  909.                                     LT_SetAttributes(Handle,GAD_LIST,
  910.                                         GTLV_Labels,    TimeDateList,
  911.                                         GTLV_Selected,    ~0,
  912.                                     TAG_DONE);
  913.  
  914.                                     Selected = ~0;
  915.  
  916.                                     LT_SetAttributes(Handle,GAD_TIME,
  917.                                         GTLV_Labels,    &EmptyList,
  918.                                         GTLV_Selected,    ~0,
  919.                                         GA_Disabled,    TRUE,
  920.                                     TAG_DONE);
  921.  
  922.                                     TimeSelected = ~0;
  923.                                 }
  924.  
  925.                                 break;
  926.  
  927.                             case GAD_IMPORT:
  928.  
  929.                                 LT_LockWindow(PanelWindow);
  930.  
  931.                                 LT_SetAttributes(Handle,GAD_LIST,
  932.                                     GTLV_Labels,    ~0,
  933.                                 TAG_DONE);
  934.  
  935.                                 MadeChanges |= ImportPanel(Entry,PhoneList,TimeDateList);
  936.  
  937.                                 DisableGadgets(Handle,TRUE,TRUE,TRUE);
  938.  
  939.                                 LT_SetAttributes(Handle,GAD_LIST,
  940.                                     GTLV_Labels,    TimeDateList,
  941.                                     GTLV_Selected,    ~0,
  942.                                 TAG_DONE);
  943.  
  944.                                 Selected = ~0;
  945.  
  946.                                 TimeSelected = ~0;
  947.  
  948.                                 LT_UnlockWindow(PanelWindow);
  949.  
  950.                                 LT_ShowWindow(Handle,TRUE);
  951.  
  952.                                 break;
  953.  
  954.                             case GAD_ADDDAY:
  955.                             case GAD_ADDDATE:
  956.  
  957.                                 LT_LockWindow(PanelWindow);
  958.  
  959.                                 MadeChanges = TRUE;
  960.  
  961.                                 if(NewNode = CreateTimeDateNode(0,1,"",2))
  962.                                 {
  963.                                     BYTE Result;
  964.  
  965.                                     if(MsgGadget -> GadgetID == GAD_ADDDAY)
  966.                                     {
  967.                                         NewNode -> Header . Month    = -1;
  968.                                         NewNode -> Header . Day        = 0;
  969.  
  970.                                         Result = DayPanel(NewNode);
  971.                                     }
  972.                                     else
  973.                                         Result = DatePanel(NewNode);
  974.  
  975.                                     if(Result)
  976.                                     {
  977.                                         AdaptTimeDateNode(NewNode);
  978.  
  979.                                         LT_SetAttributes(Handle,GAD_LIST,
  980.                                             GTLV_Labels,    ~0,
  981.                                         TAG_DONE);
  982.  
  983.                                         AddTail((struct List *)TimeDateList,&NewNode -> VanillaNode);
  984.  
  985.                                         Selected = Count++;
  986.  
  987.                                         LT_SetAttributes(Handle,GAD_LIST,
  988.                                             GTLV_Labels,        TimeDateList,
  989.                                             GTLV_Selected,        Selected,
  990.                                             GTLV_Top,        Selected,
  991.                                             GTLV_MakeVisible,    Selected,
  992.                                         TAG_DONE);
  993.  
  994.                                         TimeDateNode = NewNode;
  995.  
  996. Redisplay:                                    if(TimeList)
  997.                                             FreeVecPooled(TimeList);
  998.  
  999.                                         if(TimeList = BuildTimeList(TimeDateNode))
  1000.                                         {
  1001.                                             if(TimeSelected == ~0)
  1002.                                                 TimeSelected = 0;
  1003.  
  1004.                                             DisableGadgets(Handle,FALSE,TRUE,FALSE);
  1005.  
  1006.                                             LT_SetAttributes(Handle,GAD_PAY1,
  1007.                                                 GTIN_Number,    TimeDateNode -> Table[TimeSelected] . PayPerUnit[DT_FIRST_UNIT],
  1008.                                             TAG_DONE);
  1009.  
  1010.                                             LT_SetAttributes(Handle,GAD_MINUTES1,
  1011.                                                 GTIN_Number,    TimeDateNode -> Table[TimeSelected] . SecPerUnit[DT_FIRST_UNIT],
  1012.                                             TAG_DONE);
  1013.  
  1014.                                             LT_SetAttributes(Handle,GAD_PAY2,
  1015.                                                 GTIN_Number,    TimeDateNode -> Table[TimeSelected] . PayPerUnit[DT_NEXT_UNIT],
  1016.                                             TAG_DONE);
  1017.  
  1018.                                             LT_SetAttributes(Handle,GAD_MINUTES2,
  1019.                                                 GTIN_Number,    TimeDateNode -> Table[TimeSelected] . SecPerUnit[DT_NEXT_UNIT],
  1020.                                             TAG_DONE);
  1021.  
  1022.                                             LT_SetAttributes(Handle,GAD_TIME,
  1023.                                                 GTLV_Labels,    TimeList,
  1024.                                                 GTLV_Selected,    TimeSelected,
  1025.                                                 GA_Disabled,    FALSE,
  1026.                                             TAG_DONE);
  1027.  
  1028.                                             LT_SetAttributes(Handle,GAD_ADDTIME,
  1029.                                                 GA_Disabled,    FALSE,
  1030.                                             TAG_DONE);
  1031.  
  1032.                                             LT_SetAttributes(Handle,GAD_REMOVETIME,
  1033.                                                 GA_Disabled,    TimeDateNode -> Table[0] . Count < 2,
  1034.                                             TAG_DONE);
  1035.  
  1036.                                             LT_SetAttributes(Handle,GAD_EDITTIME,
  1037.                                                 GA_Disabled,    FALSE,
  1038.                                             TAG_DONE);
  1039.  
  1040.                                             LT_Activate(Handle,GAD_PAY1);
  1041.                                         }
  1042.                                         else
  1043.                                         {
  1044.                                             TimeDateNode = NULL;
  1045.  
  1046.                                             DisplayBeep(PanelWindow -> WScreen);
  1047.  
  1048.                                             LT_SetAttributes(Handle,GAD_LIST,
  1049.                                                 GTLV_Labels,    ~0,
  1050.                                             TAG_DONE);
  1051.  
  1052.                                             DisableGadgets(Handle,TRUE,TRUE,TRUE);
  1053.  
  1054.                                             LT_SetAttributes(Handle,GAD_LIST,
  1055.                                                 GTLV_Labels,    TimeDateList,
  1056.                                                 GTLV_Selected,    ~0,
  1057.                                             TAG_DONE);
  1058.  
  1059.                                             Selected = ~0;
  1060.  
  1061.                                             LT_SetAttributes(Handle,GAD_TIME,
  1062.                                                 GA_Disabled,    FALSE,
  1063.                                                 GTLV_Selected,    0,
  1064.                                             TAG_DONE);
  1065.  
  1066.                                             TimeSelected = ~0;
  1067.                                         }
  1068.                                     }
  1069.                                     else
  1070.                                         FreeVecPooled(NewNode);
  1071.                                 }
  1072.  
  1073.                                 LT_UnlockWindow(PanelWindow);
  1074.  
  1075.                                 LT_ShowWindow(Handle,TRUE);
  1076.  
  1077.                                 break;
  1078.  
  1079.                             case GAD_REMOVE:
  1080.  
  1081.                                 if(--Count)
  1082.                                 {
  1083.                                     if(TimeDateNode -> VanillaNode . ln_Succ -> ln_Succ)
  1084.                                         NewNode = (struct TimeDateNode *)TimeDateNode -> VanillaNode . ln_Succ;
  1085.                                     else
  1086.                                     {
  1087.                                         NewNode = (struct TimeDateNode *)TimeDateNode -> VanillaNode . ln_Pred;
  1088.  
  1089.                                         TimeSelected--;
  1090.                                     }
  1091.                                 }
  1092.  
  1093.                                 MadeChanges = TRUE;
  1094.  
  1095.                                 LT_SetAttributes(Handle,GAD_LIST,
  1096.                                     GTLV_Labels,    ~0,
  1097.                                 TAG_DONE);
  1098.  
  1099.                                 Remove(TimeDateNode);
  1100.  
  1101.                                 FreeVecPooled(TimeDateNode);
  1102.  
  1103.                                 if(Count > 1)
  1104.                                 {
  1105.                                     LT_SetAttributes(Handle,GAD_LIST,
  1106.                                         GTLV_Labels,    TimeDateList,
  1107.                                         GTLV_Selected,    Count,
  1108.                                     TAG_DONE);
  1109.  
  1110.                                     TimeDateNode = NewNode;
  1111.  
  1112.                                     goto Redisplay;
  1113.                                 }
  1114.                                 else
  1115.                                 {
  1116.                                     DisableGadgets(Handle,TRUE,TRUE,FALSE);
  1117.  
  1118.                                     LT_SetAttributes(Handle,GAD_LIST,
  1119.                                         GTLV_Labels,    TimeDateList,
  1120.                                         GTLV_Selected,    ~0,
  1121.                                     TAG_DONE);
  1122.  
  1123.                                     TimeDateNode = NULL;
  1124.                                 }
  1125.  
  1126.                                 break;
  1127.  
  1128.                             case GAD_CLONE:
  1129.  
  1130.                                 if(NewNode = CreateTimeDateNode(0,1,"",TimeDateNode -> Table[0] . Count))
  1131.                                 {
  1132.                                     MadeChanges = TRUE;
  1133.  
  1134.                                     strcpy(NewNode -> VanillaNode . ln_Name = NewNode -> Buffer,TimeDateNode -> Buffer);
  1135.  
  1136.                                     NewNode -> Header = TimeDateNode -> Header;
  1137.  
  1138.                                     CopyMem(TimeDateNode -> Table,NewNode -> Table,sizeof(struct TimeDate) * TimeDateNode -> Table[0] . Count);
  1139.  
  1140.                                     AdaptTimeDateNode(NewNode);
  1141.  
  1142.                                     LT_SetAttributes(Handle,GAD_LIST,
  1143.                                         GTLV_Labels,    ~0,
  1144.                                     TAG_DONE);
  1145.  
  1146.                                     AddTail((struct List *)TimeDateList,&NewNode -> VanillaNode);
  1147.  
  1148.                                     LT_SetAttributes(Handle,GAD_LIST,
  1149.                                         GTLV_Labels,    TimeDateList,
  1150.                                         GTLV_Selected,    Count++,
  1151.                                     TAG_DONE);
  1152.  
  1153.                                     TimeDateNode = NewNode;
  1154.  
  1155.                                     goto Redisplay;
  1156.                                 }
  1157.  
  1158.                                 break;
  1159.  
  1160.                             case GAD_EDIT:
  1161.  
  1162.                                 LT_LockWindow(PanelWindow);
  1163.  
  1164.                                 LT_SetAttributes(Handle,GAD_LIST,
  1165.                                     GTLV_Labels,    ~0,
  1166.                                 TAG_DONE);
  1167.  
  1168.                                 if(TimeDateNode -> Header . Month == -1)
  1169.                                     MadeChanges |= DayPanel(TimeDateNode);
  1170.                                 else
  1171.                                     MadeChanges |= DatePanel(TimeDateNode);
  1172.  
  1173.                                 AdaptTimeDateNode(TimeDateNode);
  1174.  
  1175.                                 LT_SetAttributes(Handle,GAD_LIST,
  1176.                                     GTLV_Labels,    TimeDateList,
  1177.                                     GTLV_Selected,    Selected,
  1178.                                 TAG_DONE);
  1179.  
  1180.                                 LT_UnlockWindow(PanelWindow);
  1181.  
  1182.                                 LT_ShowWindow(Handle,TRUE);
  1183.  
  1184.                                 break;
  1185.                         }
  1186.                     }
  1187.  
  1188.                     if(MsgClass == IDCMP_IDCMPUPDATE)
  1189.                     {
  1190.                         switch(MsgGadget -> GadgetID)
  1191.                         {
  1192.                             case GAD_TIME:
  1193.  
  1194.                                 if(Selected != ~0 && TimeSelected != ~0)
  1195.                                 {
  1196.                                     UBYTE Time = TimeDateNode -> Table[TimeSelected] . Time;
  1197.  
  1198.                                     LT_PressButton(Handle,GAD_EDITTIME);
  1199.  
  1200.                                     LT_LockWindow(PanelWindow);
  1201.  
  1202.                                     if(TimePanel(&TimeDateNode -> Table[TimeSelected] . Time))
  1203.                                     {
  1204.                                         struct List *NewTimeList;
  1205.  
  1206.                                         MadeChanges = TRUE;
  1207.  
  1208.                                         SortTimeTable(TimeDateNode);
  1209.  
  1210.                                         if(NewTimeList = BuildTimeList(TimeDateNode))
  1211.                                         {
  1212.                                             LT_SetAttributes(Handle,GAD_TIME,
  1213.                                                 GTLV_Labels,    ~0,
  1214.                                             TAG_DONE);
  1215.  
  1216.                                             if(TimeList)
  1217.                                                 FreeVecPooled(TimeList);
  1218.  
  1219.                                             TimeList = NewTimeList;
  1220.  
  1221.                                             LT_SetAttributes(Handle,GAD_TIME,
  1222.                                                 GTLV_Labels,    TimeList,
  1223.                                                 GTLV_Selected,    0,
  1224.                                                 GA_Disabled,    FALSE,
  1225.                                             TAG_DONE);
  1226.  
  1227.                                             LT_SetAttributes(Handle,GAD_LIST,
  1228.                                                 GTLV_Labels,    ~0,
  1229.                                             TAG_DONE);
  1230.  
  1231.                                             DisableGadgets(Handle,TRUE,TRUE,TRUE);
  1232.  
  1233.                                             LT_SetAttributes(Handle,GAD_LIST,
  1234.                                                 GTLV_Labels,    TimeDateList,
  1235.                                                 GTLV_Selected,    ~0,
  1236.                                             TAG_DONE);
  1237.  
  1238.                                             Selected = ~0;
  1239.  
  1240.                                             TimeSelected = ~0;
  1241.                                         }
  1242.                                         else
  1243.                                         {
  1244.                                             TimeDateNode -> Table[TimeSelected] . Time = Time;
  1245.  
  1246.                                             SortTimeTable(TimeDateNode);
  1247.  
  1248.                                             DisplayBeep(PanelWindow -> WScreen);
  1249.                                         }
  1250.                                     }
  1251.  
  1252.                                     LT_UnlockWindow(PanelWindow);
  1253.  
  1254.                                     LT_ShowWindow(Handle,TRUE);
  1255.                                 }
  1256.  
  1257.                                 break;
  1258.  
  1259.                             case GAD_LIST:
  1260.  
  1261.                                 if(Selected != ~0 && Selected > 0)
  1262.                                 {
  1263.                                     LT_PressButton(Handle,GAD_EDIT);
  1264.  
  1265.                                     LT_LockWindow(PanelWindow);
  1266.  
  1267.                                     LT_SetAttributes(Handle,GAD_LIST,
  1268.                                         GTLV_Labels,    ~0,
  1269.                                     TAG_DONE);
  1270.  
  1271.                                     if(TimeDateNode -> Header . Month == -1)
  1272.                                         MadeChanges |= DayPanel(TimeDateNode);
  1273.                                     else
  1274.                                         MadeChanges |= DatePanel(TimeDateNode);
  1275.  
  1276.                                     AdaptTimeDateNode(TimeDateNode);
  1277.  
  1278.                                     LT_SetAttributes(Handle,GAD_LIST,
  1279.                                         GTLV_Labels,    TimeDateList,
  1280.                                         GTLV_Selected,    Selected,
  1281.                                     TAG_DONE);
  1282.  
  1283.                                     LT_UnlockWindow(PanelWindow);
  1284.  
  1285.                                     LT_ShowWindow(Handle,TRUE);
  1286.  
  1287.                                     break;
  1288.                                 }
  1289.  
  1290.                                 break;
  1291.                         }
  1292.                     }
  1293.                 }
  1294.             }
  1295.             while(!Done);
  1296.  
  1297.             PopWindow();
  1298.  
  1299.             if(TimeList)
  1300.                 FreeVecPooled(TimeList);
  1301.         }
  1302.  
  1303.         LT_DeleteHandle(Handle);
  1304.     }
  1305.  
  1306.     return(MadeChanges);
  1307. }
  1308.